package tech.xs.common.framework.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import tech.xs.common.framework.domain.annotations.Dict;
import tech.xs.common.framework.domain.constant.ModuleNames;

import java.util.HashMap;
import java.util.Map;

@Dict(code = "AuthMode", name = "鉴权模式", module = ModuleNames.COMMON)
public enum AuthModeEnum implements BaseEnum {
    Token(0),
    Basic(1);


    @EnumValue
    @JsonValue
    private final int value;

    private static final Map<Integer, AuthModeEnum> mappings = new HashMap<>(values().length);

    static {
        for (AuthModeEnum item : values()) {
            mappings.put(item.getValue(), item);
        }
    }

    AuthModeEnum(int value) {
        this.value = value;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static AuthModeEnum create(int value) {
        return mappings.get(value);
    }

    @Override
    public Integer getValue() {
        return value;
    }

}
